package lv.dysnomia.server.entities

import com.google.appengine.api.datastore.Key
import com.google.appengine.api.users.User

import java.util.Date
import javax.jdo.annotations.{ IdentityType, IdGeneratorStrategy, PersistenceCapable, Persistent, PrimaryKey }

@PersistenceCapable(identityType = IdentityType.APPLICATION)
class MediaFile {
  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  var key: Key = null

  @Persistent
  var author: User = null

  @Persistent
  var date: Date = new Date

  @Persistent
  var fileName: String = null

  @Persistent
  var blobKey: String = null

  def this(author: User, date: Date, filename:String, blobKey: String) = {
    this()
    this.author = author
    this.date = date
    this.fileName = fileName
    this.blobKey = blobKey
  }

  def getKey(): Key = key

  def getAuthor(): User = author

  def getDate(): Date = date
  
  def getFileName(): String = fileName
  
  def getBlobKey(): String = blobKey

  def setAuthor(author: User): Unit = {
    this.author = author
  }

  def setDate(date: Date): Unit = {
    this.date = date
  }

  def setFileName(fileName:String): Unit = {	  
	  this.fileName = fileName
  }
  
  def setBlobKey(blobKey:String): Unit = {
	  this.blobKey = blobKey
  }
}